package com.qd.panda.stroke;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cdqidi.util.page.PageUtil;
import com.qd.common.panda.domain.entity.stroke.preferential.AppUserStrokeOrderPreferentialLogDisplayDTO;
import com.qd.common.panda.domain.entity.stroke.preferential.AppUserStrokeOrderPreferentialLogQueryDTO;
import com.qd.common.sys.util.SecurityUtils;
import com.qd.panda.service.stroke.order.UserStrokeOrderPreferentialLogHolderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * APP_用户订单优惠记录
 *
 * @author sjk
 */
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/app/userOrderPreferentialLog/")
@Slf4j
public class AppUserOrderPreferentialLogController {
    private final UserStrokeOrderPreferentialLogHolderService userStrokeOrderPreferentialLogHolderService;

    /**
     * 优惠记录列表
     *
     * @param dto 查询参数以及页数和每页显示条数
     * @return 列表信息
     */
    @GetMapping(value = "appPageUserStrokeOrderPreferentialLog")
    public IPage<AppUserStrokeOrderPreferentialLogDisplayDTO> pageOrderPreferentialLogDisplay(AppUserStrokeOrderPreferentialLogQueryDTO dto) {
        if(null == dto){
            dto = new AppUserStrokeOrderPreferentialLogQueryDTO();
        }
        dto.setUserId(SecurityUtils.getLoginUser().getUserId());
        return userStrokeOrderPreferentialLogHolderService.appPageUserStrokeOrderPreferentialLog(PageUtil.buildPage(dto), dto);
    }
}